package cn.com.greatwall.flowable.service.mapstruct;

import java.util.ArrayList;
import java.util.List;

import org.flowable.engine.history.HistoricProcessInstance;
import org.springframework.stereotype.Component;

import cn.com.greatwall.common.base.BaseMapper;
import cn.com.greatwall.flowable.service.dto.HistoricProcessInstanceDto;

/**
 * @Author herw
 * @Time 2020-11-23 16:24:04
 * @Version 1.0
 * @Description: TODO(用一句话描述该文件做什么)
 */
@Component
public class HistoricProcessInstanceMapper implements BaseMapper<HistoricProcessInstanceDto, HistoricProcessInstance> {

    @Override
    public HistoricProcessInstance toEntity(HistoricProcessInstanceDto dto) {
        // TODO Auto-generated method stub
        return null;
    }

    @Override
    public HistoricProcessInstanceDto toDto(HistoricProcessInstance entity) {
        HistoricProcessInstanceDto dto = new HistoricProcessInstanceDto();
        dto.setId(entity.getId());
        dto.setName(entity.getName());
        dto.setBusinessKey(entity.getBusinessKey());
        dto.setStartTime(entity.getStartTime());
        dto.setEndTime(entity.getEndTime());
        dto.setDurationInMillis(entity.getDurationInMillis());
        dto.setProcessDefinitionId(entity.getProcessDefinitionId());
        dto.setProcessDefinitionKey(entity.getProcessDefinitionKey());
        dto.setProcessDefinitionName(entity.getProcessDefinitionName());
        dto.setProcessDefinitionVersion(entity.getProcessDefinitionVersion());
        dto.setStartActivityId(entity.getStartActivityId());
        dto.setStartUserId(entity.getStartUserId());
        dto.setSuperProcessInstanceId(entity.getSuperProcessInstanceId());
        dto.setTenantId(entity.getTenantId());
        
        return dto;
    }

    @Override
    public List<HistoricProcessInstance> toEntity(List<HistoricProcessInstanceDto> dtoList) {
        // TODO Auto-generated method stub
        return null;
    }

    @Override
    public List<HistoricProcessInstanceDto> toDto(List<HistoricProcessInstance> entityList) {
        List<HistoricProcessInstanceDto> dtoList = new ArrayList<>();
        for (HistoricProcessInstance instance : entityList) {
            dtoList.add(toDto(instance));
        }
        return dtoList;
    }
}
